package org.jivesoftware.smackx.muc;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.packet.Packet;

class ConnectionDetachedPacketCollector
{
  private int maxPackets = SmackConfiguration.getPacketCollectorSize();
  private ArrayBlockingQueue<Packet> resultQueue;

  public ConnectionDetachedPacketCollector()
  {
    this(SmackConfiguration.getPacketCollectorSize());
  }

  public ConnectionDetachedPacketCollector(int paramInt)
  {
    this.resultQueue = new ArrayBlockingQueue(paramInt);
  }

  public Packet pollResult()
  {
    return (Packet)this.resultQueue.poll();
  }

  public Packet nextResult()
  {
    try
    {
      return (Packet)this.resultQueue.take();
    }
    catch (InterruptedException localInterruptedException)
    {
      throw new RuntimeException(localInterruptedException);
    }
  }

  public Packet nextResult(long paramLong)
  {
    try
    {
      return (Packet)this.resultQueue.poll(paramLong, TimeUnit.MILLISECONDS);
    }
    catch (InterruptedException localInterruptedException)
    {
      throw new RuntimeException(localInterruptedException);
    }
  }

  protected void processPacket(Packet paramPacket)
  {
    if (paramPacket == null)
      return;
    while (!this.resultQueue.offer(paramPacket))
      this.resultQueue.poll();
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.muc.ConnectionDetachedPacketCollector
 * JD-Core Version:    0.6.1
 */